<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>违禁词管理</title>
    <link href="__LAYUI__/css/layui.css" rel="stylesheet">
    <style>
        .sub-btn {
            display: flex;
            justify-content: flex-end;
            padding: 10px;
        }
    </style>
</head>

<body>
    <div class="layui-container layui-padding-3">
        <textarea id="forbiddenWords" rows="20"  placeholder="每个违禁词以','号分割" class="layui-textarea">{$words}</textarea>
        <div class="sub-btn">
            <button class="layui-btn layui-btn-normal" id="modifyBtn">修改</button>
        </div>
        <span>Ps:每个违禁词以","号分割</span>
    </div>
    <script src="__LAYUI__/layui.js"></script>
    <script>
        layui.use(['layer', 'form'], function () {
            var layer = layui.layer,
                form = layui.form;
            $ = layui.$
            $('#modifyBtn').click(function () {
                var forbiddenWords = $('#forbiddenWords').val();
                if (!forbiddenWords) {
                    layer.msg('请填写违禁词！', { icon: 5 });
                    return;
                }
                $.ajax({
                    url: '/admin/comment/forbidWord',
                    type: 'POST',
                    data: { words: forbiddenWords },
                    dataType: 'json',
                    success: function (res) {
                        if (res.code === 200) {
                            layer.msg('修改成功！', { icon: 6 });
                        } else {
                            layer.msg('修改失败：' + res.message, { icon: 5 });
                        }
                    },
                    error: function (err) {
                        layer.msg('修改失败，请检查网络连接！', { icon: 5 });
                    }
                });
            });
        });
    </script>
</body>

</html>